Repository navigation
Security: infrastructure findings leave their pull request or run when it is over - #666
Merged
Merged
Conversation
…n it is over #661 gave dependency findings a release when their fix pull request closed or their run ended. Infrastructure findings keep their own records and had none: a closed pull request left the record `pr_open` (the page never offered the fix again), a cancelled or failed run left it `fixing` for good, and a reopened pull request was never noticed. - `common::security_release` is generalised instead of copied: both stores are a `Claim`, and the words, the person-closed record and the holds (`closed_words`, `closed_record`, `run_end`) are shared. - The worker's `reconcile` is generic over `Claim`. Both stores use the same reads of GitHub and the run records (`Reads`), the same `pr` and `run` events, and the same sweep, first for each team, with the same bounds. - Infrastructure records get the closed record on their pull request, a hold on automatic attempts (a person asking never waits) and the time their run claimed them. - What stays this store's own: a merge is recorded and never closes a finding (only a read of the account does); a draft the replacement guard holds is not closed and is left as it is; a finding on its runbook stays there until its code or target changes; a pull request the record never learned goes through the guard before it is recorded; a fix round that ends without settling its pull request becomes the guard's second step (a draft), never a ready pull request. - "Open fix PR" and Retry check the record against GitHub first. Retry on an infrastructure fix run whose pull request is gone is a new request for the finding as it stands. Incident case `as_infra_closed_pr_keeps_record`.
Both sides kept: the incident list and its table carry `ar`, `as` and `at` in order. The draft hold still goes through description::save.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #661, for the gap it named. Infrastructure findings keep their own records (
INFRAFINDING#) and nothing released them when a claim ended:pr_open. The Infrastructure tab kept the closed pull request and never offered "Open fix PR" again.fixingfor good. This store had no fallback at all.Only a read of the AWS account ever changed such a record. They now have the same guarantees as dependency findings, through the same code.
Changes
common::security_releasegains theClaimtrait. Dependency findings and infrastructure records both implement it. The words, the person-closed record and the holds are shared (closed_words,closed_record,run_end), so the two stores cannot drift.worker/src/passes/security_release.rs::reconcileis generic overClaim. Both stores use the same reads of GitHub and the run records (Reads), the sameprandrunevents from the gateway (no new gateway events were needed: the webhook filter already coverscoderhelm/security-infra-branches), and the same sweep: first for each team, on its own clock, at most 100 pull requests and 50 runs per team per sweep, the rest in turn.common/src/infra_vuln/records.rs): the pull request record getsclosed_at,closed_by,closed_by_person; the record getshold_until,claimed_atand the note shown after a person ended its run. Records stored before read as before.on_pr_opened, so the guard reads it first.as_infra_closed_pr_keeps_recordand its row indocs/incidents.md.Records that are stale today are repaired by the first sweep after deploy, with no step by a person, as for dependency findings.
The dashboard change that offers the fix again on the Infrastructure tab is a separate small pull request in CoderHelm/coderhelm.
Verification
cargo fmt --check --all,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepass locally: common 2,301 passed, gateway 913, worker 1,784, none failed.newly_drafted), not against GitHub.